<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>倒计时</title>
</head>
<style>
    #time {
        text-align: center;
        margin-top: 100px;
    }
</style>

<body>
    <div id="time"></div>
</body>
<script>

    function getRTime() {
        var EndTime = new Date('2019/07/30 19:00:00');
        var NowTime = new Date();
        var t = EndTime.getTime() - NowTime.getTime();
        var d = Math.floor(t / 1000 / 60 / 60 / 24);
        var h = Math.floor(t / 1000 / 60 / 60 % 24);
        var m = Math.floor(t / 1000 / 60 % 60);
        var s = Math.floor(t / 1000 % 60);
        var str = `距离XXX还有${d}天${h}小时${m}分钟${s}秒`;
        time.innerHTML = str;
    };
    getRTime();
    setInterval(getRTime, 1000);

</script>

</html>